<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<div>
    <%!
        // 声明成员变量 - 被所有客户端共享
        private int counter = 0;

        // 同步方法确保线程安全
        public synchronized void incrementCounter() {
            counter++;
        }
    %>
    <%
        incrementCounter();
    %>
    <p>欢迎访问本网站！</p>
    <p>您是第<%= counter %>个访问本站的客户。</p>
</div>
</body>
</html>